package com.zhaoguang.car.controller;


import com.zhaoguang.car.common.RespBean;
import com.zhaoguang.car.entity.UserCollect;
import com.zhaoguang.car.service.UserRelativeService;
import com.zhaoguang.car.vo.ListCarVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/usercollect")
public class UserRelativeController {

    @Autowired
    UserRelativeService UserRelativeService;

    @RequestMapping("/findCarIfCollection")
    public RespBean findCarIfCollection(UserCollect uc) {
        String str = UserRelativeService.findCarIfCollection(uc);

        return RespBean.success(str);
    }

    @RequestMapping("/saveCollection")
    public RespBean saveCollection(UserCollect uc){
        int result = UserRelativeService.saveCollection(uc);

        return RespBean.success("收藏成功");
    }

    @RequestMapping("/deleteCollection")
    public RespBean deleteCollection(UserCollect uc){
        int result = UserRelativeService.deleteCollection(uc);

        return RespBean.success("取消收藏成功");
    }

    @RequestMapping("/findUserCollection")
    public RespBean findUserCollection(int userId){
        List<ListCarVo> listCollection = UserRelativeService.findUserCollection(userId);

        return RespBean.success("查询成功", listCollection);
    }
}
